package com.jinmdz.fmis.api.api.controller;

import com.jinmdz.fmis.api.api.model.cremation.certificate.CremationCertificateItem;
import com.jinmdz.fmis.api.api.model.cremation.certificate.CremationCertificatePrintingAllData;
import com.jinmdz.fmis.api.api.model.cremation.certificate.CremationCertificatePrintingItem;
import com.jinmdz.fmis.api.api.model.cremation.certificate.CremationCertificatePrintingSaveData;
import com.jinmdz.fmis.api.api.model.funeral.BusinessCodeData;
import com.jinmdz.fmis.api.api.service.CremationCertificatePrintingService;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.core.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * 火化证打印相关接口
 *
 * @author GuanKui
 * @date 2020/2/19 10:59
 */
@Api(description = "火化证打印相关接口")
@RestController()
@RequestMapping("/api/cremation-certificate-printing")
public class CremationCertificatePrintingController extends BaseController {

    @Resource
    private CremationCertificatePrintingService cremationCertificatePrintingService;

    /**
     * 根据funeral_dead表中businessCode加载逝者火化证件打印页面所有信息
     *
     * @param data 打印加载信息
     * @return
     * @author GuanKui
     * @date 2020/2/19  11:11
     */
    @ApiOperation(value = "根据funeral_dead表中businessCode加载逝者火化证件打印页面所有信息",
            notes = "根据businessCode加载信息，包括：逝者信息、逝者家属信息、承办人信息、操作类型字典信息和打印历史记录信息")
    @PostMapping("/load-cremation-certificate-printing-all")
    public BaseResult<CremationCertificatePrintingItem> loadCremationCertificatePrintingAll(@RequestBody CremationCertificatePrintingAllData data) {
        return resultHandler(data, userItem -> cremationCertificatePrintingService.loadCremationCertificatePrintingAll(data));
    }

    /**
     * 保存火化证打印信息
     *
     * @param data 保存打印信息
     * @return
     * @author GuanKui
     * @date 2020/2/19  11:44
     */
    @ApiOperation(value = "保存火化证打印信息，保存成功后自动带回页面刷新需要数据", notes = "保存火化证打印历史记录，界面上先进行保存操作，成功后触发打印机打印功能。")
    @PostMapping("/save-cremation-certificate-printing")
    public BaseResult<CremationCertificatePrintingItem> saveCremationCertificatePrinting(@RequestBody CremationCertificatePrintingSaveData data) {
        return resultHandler(data, userItem -> cremationCertificatePrintingService.saveCremationCertificatePrinting(userItem, data));
    }

    /**
     * 根据funeral_dead表中businessCode加载打印火化证/火化证明信息
     *
     * @param data 业务编码
     * @return
     * @author LiCongLu
     * @date 2020-04-10 15:30
     */
    @ApiOperation(value = "根据funeral_dead表中businessCode加载打印火化证/火化证明信息", notes = "按照业务编码加载打印火化证/火化证明信息")
    @PostMapping("/load-print-cremation-certificate")
    public BaseResult<CremationCertificateItem> loadPrintCremationCertificateWithBusinessCode(@RequestBody BusinessCodeData data) {
        return resultHandler(data, userItem -> cremationCertificatePrintingService.loadPrintCremationCertificateWithBusinessCode(userItem, data));
    }

}
